home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ccdl150l.zip
/
DATA
/
STRTOUL.C
< prev
Wrap
C/C++ Source or Header
|
1996-07-02
|
487b
|
31 lines
#include <stdlib.h>
#include <ctype.h>
unsigned long strtoul(const char *s, char **endptr, int radix)
{
int val = 0;
while (isspace(*s)) s++;
if (*s == '0') {
radix = 8;
s++;
if (*s == 'x' || *s == 'X') {
radix = 16;
s++;
}
}
while(isalnum(*s)) {
unsigned temp = toupper(*s++)-'0';
if (temp >= 10)
temp -= 7;
if (temp >= radix) {
s--;
break;
}
val*= radix;
val += temp;
}
if (endptr)
*endptr = s;
return val;
}